﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
namespace DAO
{
    public class GopYDAO
    {
         DataTable dt;
        List<string> dsThamSo;
        ArrayList dsGiaTri;
       
        
        public GopYDAO()
        {
            dt = new DataTable();
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            
        }
        public DataTable layThongTinGopY(string loaiThacMac,bool trangThai,string dieuKien,int kichThuocTrang,int trangThu)
        {
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            dsThamSo.Add("@loaiThacMac");
            dsThamSo.Add("@trangThai");
            dsThamSo.Add("@dieuKien");
            dsThamSo.Add("@kichThuocTrang");
            dsThamSo.Add("@trangThu");
   
            dsGiaTri.Add(loaiThacMac);
            dsGiaTri.Add(trangThai);
            dsGiaTri.Add(dieuKien);
            dsGiaTri.Add(kichThuocTrang);
            dsGiaTri.Add(trangThu);
            dt = DataProvider.ExecuteStoreProc("sp_layThongTinGopY", dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable layThongTinGopY(string loaiThacMac,string dieuKien, int kichThuocTrang, int trangThu)
        {
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            dsThamSo.Add("@loaiThacMac");
            dsThamSo.Add("@dieuKien");
            dsThamSo.Add("@kichThuocTrang");
            dsThamSo.Add("@trangThu");

            dsGiaTri.Add(loaiThacMac);
            dsGiaTri.Add(dieuKien);
            dsGiaTri.Add(kichThuocTrang);
            dsGiaTri.Add(trangThu);
            dt = DataProvider.ExecuteStoreProc("sp_layThongTinGopY_KhongCoTrangThai", dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable laySoDongGopY(string loaiThacMac, bool trangThai, string dieuKien)
        {
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            dsThamSo.Add("@loaiThacMac");
            dsThamSo.Add("@trangThai");
            dsThamSo.Add("@dieuKien");
            dsGiaTri.Add(loaiThacMac);
            dsGiaTri.Add(trangThai);
            dsGiaTri.Add(dieuKien);
            dt = DataProvider.ExecuteStoreProc("sp_laySoDongGopY", dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable  laySoDongGopY(string loaiThacMac, string dieuKien)
        {
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            dsThamSo.Add("@loaiThacMac");
            dsThamSo.Add("@dieuKien");
            dsGiaTri.Add(loaiThacMac);
            dsGiaTri.Add(dieuKien);
            dt = DataProvider.ExecuteStoreProc("sp_laySoDongGopY_KhongCoTrangThai", dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable layChiTietThongTinGopY(string ID)
        {
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            dsThamSo.Add("@ID");
            dsGiaTri.Add(ID);

            dt = DataProvider.ExecuteStoreProc("sp_layThongTinGopYChiTiet", dsThamSo, dsGiaTri);
            return dt;
        }
        public int capNhatGopY(string maNhanVien, int ID)
        {
            int n = 0;
            string sql = "update GopY set ID_nhanVien = '"+maNhanVien+"',tinhTrang = 'True' where ID_gopY = " + ID;
            n = DataProvider.ExecuteNoneQuery(sql);
            return n;
        }
    }
}
